//
//  SegmentHeaderView.m
//  BaseProject
//
//  Created by 王洋 on 2020/8/6.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "SegmentHeaderView.h"

@implementation SegmentHeaderView

- (void)awakeFromNib {
    [super awakeFromNib];

    WEAKSELF
    self.lab1.userInteractionEnabled = YES;
    [self.lab1 addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (weakSelf.SegmentHeaderViewBlock) {
            weakSelf.SegmentHeaderViewBlock(SegmentHeaderSelType_coupon);
        }
    }];
    
    self.lab2.userInteractionEnabled = YES;
    [self.lab2 addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (weakSelf.SegmentHeaderViewBlock) {
            weakSelf.SegmentHeaderViewBlock(SegmentHeaderSelType_hall);
        }
    }];
    
    self.lab3.userInteractionEnabled = YES;
    [self.lab3 addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (weakSelf.SegmentHeaderViewBlock) {
            weakSelf.SegmentHeaderViewBlock(SegmentHeaderSelType_menu);
        }
    }];
    
    self.lab4.userInteractionEnabled = YES;
    [self.lab4 addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (weakSelf.SegmentHeaderViewBlock) {
            weakSelf.SegmentHeaderViewBlock(SegmentHeaderSelType_dynamic);
        }
    }];
    
    self.lab5.userInteractionEnabled = YES;
    [self.lab5 addGestureTapEventHandle:^(id  _Nonnull sender, UITapGestureRecognizer * _Nonnull gestureRecognizer) {
        if (weakSelf.SegmentHeaderViewBlock) {
            weakSelf.SegmentHeaderViewBlock(SegmentHeaderSelType_evaluate);
        }
    }];
}

- (void)clearStatus {
    
    self.tag1.hidden = YES;
    self.tag2.hidden = YES;
    self.tag3.hidden = YES;
    self.tag4.hidden = YES;
    self.tag5.hidden = YES;

    self.lab1.textColor = UIColorHex(0x333333);
    self.lab2.textColor = UIColorHex(0x333333);
    self.lab3.textColor = UIColorHex(0x333333);
    self.lab4.textColor = UIColorHex(0x333333);
    self.lab5.textColor = UIColorHex(0x333333);

}

- (void)fillWithType:(SegmentHeaderSelType)type {

    [self clearStatus];
    switch (type) {
        case SegmentHeaderSelType_coupon:{
            self.tag1.hidden = NO;
        } break;
        case SegmentHeaderSelType_hall:{
            self.tag2.hidden = NO;
        } break;
        case SegmentHeaderSelType_menu:{
            self.tag3.hidden = NO;
        } break;
        case SegmentHeaderSelType_dynamic:{
            self.tag4.hidden = NO;
        } break;
        case SegmentHeaderSelType_evaluate:{
            self.tag5.hidden = NO;
        } break;
        default:
            break;
    }
    
    
}


@end
